﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Manage/MasterPage.master" AutoEventWireup="true" CodeFile="MyInvited.aspx.cs" Inherits="Manage_MyInvited" %>
<%@ Register Src="~/Manage/CmsMessageBox.ascx" TagPrefix="cms" TagName="MessageBox" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <script type="text/javascript">
        $(document).ready(function () {
            $('#SearchBar').width($('#Body table.List').width());

            $('a[iid]').click(function () {
                if (confirm('你确认接收本次授课邀请吗？')) {
                    var o = $(this);
                    $.ajax({
                        type: "POST",
                        url: "./AcceptInvited.aspx",
                        data: "iid=" + o.attr("iid"),
                        success: function (msg) {
                            if (msg.indexOf("SUCCESS") != -1) {
                                alert('您已经接受邀请。');
                                document.location = './MyInvited.aspx?page=<%=CurrentPage.Value %>';
                            } else if (msg.indexOf("ERROR") != -1) {
                                alert('发生错误，请稍后再试。');
                            }
                        },
                        error: function (msg) {
                            alert("发生错误: " + msg.responseText);
                        }
                    });
                }
            });
        });
    </script>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="body" Runat="Server">
    <cms:MessageBox id="MessageBox" runat="server" />
    <asp:HiddenField ID="CurrentPage" runat="server" Value="1" />
    <div id="SearchBar">
        <table cellpadding="0" cellspacing="0">
            <tr>
                <td><asp:TextBox ID="SearchCondition" runat="server" SkinID="SearchBox" /><asp:HiddenField ID="SearchConditionHidden" runat="server" /></td>
                <td><asp:Button ID="Search" runat="server" Text="查询" 
                        onclick="Search_Click"/></td>
            </tr>
        </table>
    </div>
    <div style="clear: both">
        <asp:Repeater ID="InvitesView" runat="server">
            <HeaderTemplate>
                <table class="List" cellspacing="1">
                    <tr class="header">
                        <th style="width:100px">邀请人</th>
                        <th style="width:130px">邀请时间</th>
                        <th style="width:150px">讲授课程</th>
                        <th style="width:300px">描述</th>
                        <th style="width:100px">状态</th>
                    </tr>
            </HeaderTemplate>
            <AlternatingItemTemplate>
                <tr class="even">
                    <td align="center" style="width:100px"><%#Eval("Name") %></td>
                    <td align="center" style="width:130px"><%#string.Format("{0:yyyy-MM-dd HH:mm}", Eval("Time")) %></td>
                    <td align="center" style="width:150px"><%#Eval("Course") %></td>
                    <td align="center" style="width:300px">
                        <asp:HyperLink runat="server" NavigateUrl='<%#"./ViewInvite.aspx?iid=" + Eval("InviteID") %>'><%#Eval("Title") %></asp:HyperLink>
                    </td>
                    <td align="center" style="width:100px">
                        <%#(Eval("Accepted") != null) ? 
                        "已应邀" : 
                        (DateTime.Now.CompareTo(Convert.ToDateTime(Eval("Time")).AddDays(3)) < 0) ? 
                        "<a href='javascript:void(0);' iid='" + Eval("ID") + "'>接受邀请</a>"
                        : 
                        "<font color='#ff0000'>已过期</font>"%>
                    </td>
                </tr>
            </AlternatingItemTemplate>
            <ItemTemplate>
                <tr class="odd">
                    <td align="center" style="width:100px"><%#Eval("Name") %></td>
                    <td align="center" style="width:130px"><%#string.Format("{0:yyyy-MM-dd HH:mm}", Eval("Time")) %></td>
                    <td align="center" style="width:150px"><%#Eval("Course") %></td>
                    <td align="center" style="width:300px">
                        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#"./ViewInvite.aspx?iid=" + Eval("InviteID") %>'><%#Eval("Title") %></asp:HyperLink>
                    </td>
                    <td align="center" style="width:100px">
                        <%#(Eval("Accepted") != null) ? 
                        "已应邀" :
                        (DateTime.Now.CompareTo(Convert.ToDateTime(Eval("Time")).AddDays(3)) < 0) ? 
                        "<a href='javascript:void(0);' iid='" + Eval("ID") + "'>接受邀请</a>"
                        : 
                        "<font color='#ff0000'>已过期</font>"%>
                    </td>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
                <tr class="Footer">
                    <td colspan="5" align="center" valign="middle">
                        <table cellpadding="0" cellspacing="0">
                            <tr>
                                <td>共 <%=pds.DataSourceCount %> 条记录</td>
                                <td><asp:LinkButton ID="FirstButton" runat="server" SkinID="FirstButton" OnCommand="ChangePage" CommandArgument="F">&nbsp;</asp:LinkButton></td>
                                <td><asp:LinkButton ID="PreviousButton" runat="server" SkinID="PreviousButton" OnCommand="ChangePage" CommandArgument="P">&nbsp;</asp:LinkButton></td>
                                <td>第 <%=pds.CurrentPageIndex+1 %> 页 / 共 <%=pds.PageCount %> 页</td>
                                <td><asp:LinkButton ID="NextButton" runat="server" SkinID="NextButton" OnCommand="ChangePage" CommandArgument="N">&nbsp;</asp:LinkButton></td>
                                <td><asp:LinkButton ID="LastButton" runat="server" SkinID="LastButton" OnCommand="ChangePage" CommandArgument="L">&nbsp;</asp:LinkButton></td>
                                <td><asp:TextBox ID="GotoPage" runat="server" Width="30px"></asp:TextBox></td>
                                <td><asp:LinkButton ID="GotoButton" runat="server" SkinID="GotoButton" OnCommand="ChangePage" CommandArgument="G">&nbsp;</asp:LinkButton></td>
                            </tr>
                        </table>
                    </td>
                </tr>
                </table>
            </FooterTemplate>
        </asp:Repeater>
    </div>
</asp:Content>